import axios from 'axios'
import { apiBase } from '@config/host'
import { message } from '@config/urls'
import format from 'format'

const headers = {
  'userid': 'oMIXe0XEDiQ3jAkiPPjSJkK6BpUY',
  'dpmid': '1'
}

// 获取消息列表
const getMessageList = function (data) {
  return new Promise((resolve, reject) => {
    axios.get(apiBase + message.getMessageList, {
      params: data,
      headers
    }).then(res => {
      resolve && resolve(res.data)
    }).catch(errMsg => {
      reject && reject(errMsg)
    })
  })
}

// 获取消息详情
const getMessageDetail = function (id) {
  return new Promise((resolve, reject) => {
    axios.get(apiBase + format(message.getMessageDetail, id), {
      headers
    }).then(res => {
      resolve && resolve(res.data)
    }).catch(errMsg => {
      reject && reject(errMsg)
    })
  })
}

export {
  getMessageList,
  getMessageDetail
}